package com.david.trade.common.enums;


public enum SpotOpCode {


    SUCCESS("0", "成功"),


    SYSTEM_ERROR("500", "系统异常"),
    //10 参数类错误 ----------------------------------


    ACCOUNT_BANNED("SPOT001", "你的账户已被冻结，请联系客服"),
    ASSETS_NOT_ENOUGH("SPOT002", "资产不足"),
    PARAM_ERROR("SPOT003", "参数错误"),
    FREQUENTLY_ASSIST("SPOT004","超过频率限制"),
    ASSETS_NOT_UNFROZEN("SPOT005", "资产不够解冻"),
    ASSETS_EXCEPET("SPOT006", "资产异常"),
    CONTRACT_EXIST("SPOT007", "币对不存在"),
    COIN_EXIST("SPOT008", "币种不存在"),
    PIPELINE_BLOCKED("SPOT009", "流水线被阻塞"),
    ORDER_TIMEOUT("SPOT010", "订单超时"),
    ;


    /**
     * 异常状态码
     */
    private final String code;

    /**
     * 信息
     */
    private final String message;

    SpotOpCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 获取状态码
     *
     * @return
     */
    public String getCode() {
        return code;
    }

    /**
     * 获取信息
     *
     * @return
     */
    public String getMessage() {
        return message;
    }

    public boolean isSuccess() {
        return this.code == SpotOpCode.SUCCESS.getCode();
    }

    public static SpotOpCode getMessageByCode(String message) {
        for (SpotOpCode error : SpotOpCode.values()) {
            if (error.message.equals(message)) {
                return error;
            }
        }
        return null;
    }

}
